package com.zxm.ex.common.vo;

import com.zxm.ex.common.exception.BackendException;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

@Data
@Slf4j
public  class BaseResultVo<M> {

    private String msg;
    private int code;
    private M data;

    public static BaseResultVo success(){
        BaseResultVo<Object> objectBaseResultVo = new BaseResultVo<>();
        objectBaseResultVo.setCode(200);
        return objectBaseResultVo;
    }
    public static<M> BaseResultVo success(M m){
        BaseResultVo<Object> objectBaseResultVo = new BaseResultVo<>();
        objectBaseResultVo.setCode(200);
        objectBaseResultVo.setData(m);
        return objectBaseResultVo;
    }

    public static BaseResultVo exception(BackendException e) {
        BaseResultVo<Object> objectBaseResultVo = new BaseResultVo<>();
        objectBaseResultVo.setCode(e.getCode());
        objectBaseResultVo.setData(e);
        return objectBaseResultVo;

    }
}
